package kr.hkit.powerjava.chapter22.collection;

import java.util.HashMap;
import java.util.Map;

//564페이지 예제

class Student {
	int number;
	String name;

	public Student(int number, String name) {
		this.number = number;
		this.name = name;
	}

	@Override
	public String toString() {
		return String.format("%s", name);
	}

}

public class MapTest2 {
	public static void main(String[] args) {
		Map<String, Student> st = new HashMap<String, Student>();
		st.put("20090001", new Student(20090001, "구준표"));
		st.put("20090002", new Student(20090002, "금잔디"));
		st.put("20090003", new Student(20090003, "윤지후"));
		System.out.println(st); //전체출력

		st.remove("20090002");
		System.out.println(st); //금잔디 삭제
		
		st.put("20090003", new Student(20090003, "소이정")); 
		System.out.println(st);
		System.out.println(st.get("20090003"));

		for (Map.Entry<String, Student> s : st.entrySet()){
			String key = s.getKey();
			Student value = s.getValue();
			System.out.println("key= "+key+", Value= "+value);
			
		}
	}
}
